//
//  BankCardTableViewCell.m
//  Kjs-iOS
//
//  Created by 江伟 on 16/6/24.
//  Copyright © 2016年 jmhz. All rights reserved.
//

#import "BankCardTableViewCell.h"
#import "CommonUtil.h"
@interface BankCardTableViewCell ()
@property (nonatomic,strong) NSString *bankCardId;
@end
@implementation BankCardTableViewCell

- (void)awakeFromNib {
    // Initialization code
    self.cardView.layer.cornerRadius = 5;
    self.cardView.layer.masksToBounds = YES;
    self.setMainCardBtn.layer.cornerRadius = 10;
    self.setMainCardBtn.layer.masksToBounds = YES;
    self.delBindBtn.layer.cornerRadius = 15;
    self.delBindBtn.layer.masksToBounds = YES;
    [self.bigLogImageView setAlpha:0.4];
    [self.smallLogImageView setBackgroundColor:[UIColor whiteColor]];
    [self.smallLogImageView setAlpha:0.4];
    self.smallLogImageView.layer.cornerRadius = self.smallLogImageView.frame.size.height/2;
    self.smallLogImageView.layer.masksToBounds = YES;
    [self sendSubviewToBack:self.contentView];
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];
}

- (void)setBankCard:(BankCard *)bankCard
{
    NSLog(@"银行卡传进来了=%@",bankCard);
    //默认主卡
    
    if ([bankCard.isMainTradeCard isEqualToString:@"1"]) {
        [self.setMainCardBtn setTitle:@"默认主卡" forState:UIControlStateNormal];
        [self.setMainCardBtn setEnabled:NO];
    }else if ( [bankCard.isMainTradeCard isEqualToString:@"0"] ){
        [self.setMainCardBtn setTitle:@"设为主卡" forState:UIControlStateNormal];
        [self.setMainCardBtn addTarget:self action:@selector(setMainCard) forControlEvents:UIControlEventTouchUpInside];
        [self.setMainCardBtn setEnabled:YES];
    }
    self.smallLogImageView.image = [UIImage imageNamed:bankLogoImageArray[bankCard.bankCardNameType]];
    self.bigLogImageView.image = [UIImage imageNamed:bankBigLogoImageArray[bankCard.bankCardNameType]];
    self.bankCardCategoryLab.text = @"储蓄卡";
    self.bankCardNameLab.text = bankNameArray[bankCard.bankCardNameType];
    self.bankCardNumLab.text = bankCard.bankCardNum;
    [self.delBindBtn setTitle:@"解绑" forState:UIControlStateNormal];
    switch ([CommonUtil getColorByBankType:bankCard.bankCardNameType]) {
        case red:
            [self.cardView setBackgroundColor:[UIColor redColor]];
            break;
        case blue:
            [self.cardView setBackgroundColor:[UIColor colorWithRed:88/255.0f green:188/255.0f blue:231/255.0f alpha:1]];
        default:
            [self.cardView setBackgroundColor:[UIColor colorWithRed:88/255.0f green:188/255.0f blue:231/255.0f alpha:1]];
            break;
    }
    self.bankCardId = bankCard.bankCardId;
}
-(void)setMainCard
{
    NSLog(@"调用");
    if (self.setMainCardOperate) {
        self.setMainCardOperate(self.bankCardId);
    }
}


@end
